<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>主页</title>
    <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
</head>
<body>
欢迎，{{ username }} <a href="/loginout/">注销</a>
<h4>所有可执行的流程：</h4>
<dl>
    <dt>Coffee</dt>
    <dt>Milk</dt>
</dl>
<input id="run_button" type="button" value="执行测试用例" onclick="run()">
<a hidden target="_blank">下载结果</a>
{% csrf_token %}
<script>
    function run() {
        const username = '{{ username }}';
        let tokenInfo;
        if (username === 'lch') {
            alert('当前用户是超级管理员，请使用普通用户登录')
        } else {
            tokenInfo = $('input[name="csrfmiddlewaretoken"]').val();
            $.post("/master/run/", {'csrfmiddlewaretoken': tokenInfo}, function(data) {
                if (data.status) {
                    $('#run_button').next().attr('href', data.url);
                    $('#run_button').next().show();
                }
            })
        }
    }
</script>
</body>
</html>